import datetime
import socket
import time




client = socket.socket()
addr = '192.168.1.105'
try:
    client.connect((addr, 8000))  # 向接收端发起连接
except ConnectionRefusedError:
    print("无法连接接收端请确保地址正确且接收端开启:",addr)
    exit(1)
# 连接成功发消息

client.sendall('Connection OK'.encode('utf-8'))
print("连接成功")

# 等待服务端回消息
reply = client.recv(1024)
print(reply.decode('utf-8'))

warning_sound = '1.mp3'


i = 1
Command = False
while True:
    sdata = input("输入命令（输入Sound 播放声音，输入shutdown/restart关机重启，输入其他传输数据）:")
    if sdata == 'quit':
        break
    elif sdata == 'shutdown/restart':
        break
    client.sendall(sdata.encode('utf-8'))
    if Command == True:
        if sdata == 'qcommand':
            Command = False
    if sdata == 'command':
        Command = True

